package cn.edu.neu.softlab633.influencemaximization.sy.M_TLTGreedy;

import cn.edu.neu.softlab633.influencemaximization.sy.bean.CELF.CELFQueue;
import cn.edu.neu.softlab633.influencemaximization.sy.bean.CELF.CELFQueueEle;
import cn.edu.neu.softlab633.influencemaximization.sy.bean.Graph;
import cn.edu.neu.softlab633.influencemaximization.sy.bean.MarginGain;
import cn.edu.neu.softlab633.influencemaximization.sy.bean.Potentiality;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by Jason on 2017/5/11.
 */
public class M_Candidate_Update {
    public static void candidateUpdate(int k, int p, CELFQueue celfQueue, ArrayList<Potentiality> potentialities, MarginGain gain, Graph graph) {
        int candidateNum = (int) (Math.pow(2, p) * k);
        Set<Integer> activedSet = gain.getMarginGainNode();
        celfQueue.removeAll(activedSet);
        potentialities.removeAll(activedSet);
        if (celfQueue.size() < candidateNum / 4) {
            // 获取celf队列的最后一个元素
            int activedNum = 0;
            int round = 0;
            for (int i = 0; i < candidateNum / 2; i++) {
                int id = potentialities.get(0).getId();
                celfQueue.add(new CELFQueueEle(id, new MarginGain(activedNum, new HashSet<Integer>()), round));
                // remove from potentiallities
                potentialities.remove(0);
            }
        }
    }
}
